/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.lvyh.lightframe.cloud.business.usercenter.service;


import com.lvyh.lightframe.cloud.common.model.LoginAppUser;
import com.lvyh.lightframe.cloud.common.model.PageResult;
import com.lvyh.lightframe.cloud.common.model.Result;
import com.lvyh.lightframe.cloud.common.model.SysRole;
import com.lvyh.lightframe.cloud.common.model.SysUser;

import java.util.List;
import java.util.Map;

public interface SysUserService {
    /**
     * 获取UserDetails对象
     */
    LoginAppUser findByUsername(String username) throws Exception;

    LoginAppUser findByOpenId(String username) throws Exception;

    LoginAppUser findByMobile(String username) throws Exception;

    /**
     * 通过SysUser 转换为 LoginAppUser，把roles和permissions也查询出来
     */
    LoginAppUser getLoginAppUser(SysUser sysUser) throws Exception;

    /**
     * 根据用户名查询用户
     */
    SysUser selectByUsername(String username) throws Exception;

    SysUser getById(Integer id) throws Exception;

    boolean updateById(SysUser sysUser) throws Exception;

    /**
     * 根据手机号查询用户
     */
    SysUser selectByMobile(String mobile) throws Exception;

    /**
     * 根据openId查询用户
     */
    SysUser selectByOpenId(String openId) throws Exception;

    /**
     * 用户分配角色
     */
    void setRoleToUser(Integer id, List<Integer> roleIds) throws Exception;

    Result updatePassword(Integer id, String oldPassword, String newPassword) throws Exception;

    PageResult<SysUser> findUsers(Map<String, Object> params) throws Exception;

    List<SysRole> findRolesByUserId(Integer userId) throws Exception;

    Result updateEnabled(Map<String, Object> params) throws Exception;

    Result update(SysUser sysUser) throws Exception;

    Result add(SysUser sysUser) throws Exception;

    boolean delUser(Integer id) throws Exception;
}
